﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.Authorization.API.Application.Command.OrganizationCommand;

namespace S.Authorization.API.Controllers.Organization
{
    [Route("api/[controller]")]
    [ApiController]
    public class ColumnManagementController : ControllerBase
    {
        private IMediator mediator;
        public ColumnManagementController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 新增栋舍
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpPost("AddColumnManagement")]
        public async Task<IActionResult> AddColumnManagement(ColumnManagementCreateCommand column)
        {
            var result = await mediator.Send(column);
            return Ok(result);
        }
        /// <summary>
        /// 新增羊场
        /// </summary>
        /// <param name="column"></param>
        /// <returns></returns>
        [HttpPost("AddSheepFrom")]
        public async Task<IActionResult> AddSheepFrom(SheepFromCommand column)
        {
            var result = await mediator.Send(column);
            return Ok(result);
        }
        /// <summary>
        /// 新增栏位
        /// </summary>
        /// <param name="column"></param>
        /// <returns></returns>
        [HttpPost("AddFielModel")]
        public async Task<IActionResult> AddFielModel(FieldModelCreateCommand column)
        {
            var result = await mediator.Send(column);
            return Ok(result);
        }
        /// <summary>
        /// 栋舍删除
        /// </summary>
        /// <param name="BuildingManagementId"></param>
        /// <returns></returns>
        [HttpDelete("DeleteColum")]
        public async Task<IActionResult> DeleteColum(int BuildingManagementId)
        {
            return Ok(await mediator.Send(new ColumnManagementDelete() { BuildingManagementId = BuildingManagementId }));
        }
        /// <summary>
        /// 栏位删除
        /// </summary>
        /// <param name="ColumnManagementId"></param>
        /// <returns></returns>
        [HttpDelete("DeleteFile")]
        public async Task<IActionResult> DeleteFile(int ColumnManagementId)
        {
            return Ok(await mediator.Send(new FieldModelDelete() { ColumnManagementId = ColumnManagementId }));
        }
        /// <summary>
        /// 栋舍修改
        /// </summary>
        /// <param name="colum"></param>
        /// <returns></returns>
        [HttpPut("UpdateFile")]
        public async Task<IActionResult> UpdateFile(ColumUpdate colum)
        {
            
            return Ok(await mediator.Send(colum));
        }
        /// <summary>
        /// 栋舍删除
        /// </summary>
        /// <param name="colum"></param>
        /// <returns></returns>
        [HttpDelete("DeleteFileMore")]
        public async Task<IActionResult> DeleteFileMore(string ids)
        {
            return Ok(await mediator.Send(new ColumnDeleteMore() { Ids=ids}));
        }
        /// <summary>
        /// 羊场删除
        /// </summary>
        /// <param name="colum"></param>
        /// <returns></returns>
        [HttpDelete("SheepFromDelete")]
        public async Task<IActionResult> SheepFromDelete(int id)
        {
            return Ok(await mediator.Send(new SheepFromDeleteCommand() { SheepFarmsId = id }));
        }
        /// <summary>
        /// 羊场修改
        /// </summary>
        /// <param name="colum"></param>
        /// <returns></returns>
        [HttpPut("SheepFromUpdate")]
        public async Task<IActionResult> SheepFromUpdate(SheepFromUpdateCommand command)
        {
            return Ok(await mediator.Send(command));
        }
        /// <summary>
        /// 羊场批量删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpDelete("DeleteMoreSheepFrom")]
        public async Task<IActionResult> DeleteMoreSheepFrom(string ids)
        {
            return Ok(await mediator.Send(new SheepFromDeleteMoreCommand() { Ids = ids }));
        }
    }
}
